import type { Restaurant, Cuisine } from './types';

export function drawRandom(pool: Restaurant[]): Restaurant | null {
  if (!pool.length) return null;
  const idx = Math.floor(Math.random() * pool.length);
  return pool[idx] ?? null;
}

export function drawWithExclusions(pool: Restaurant[], excluded: Cuisine[]): Restaurant | null {
  const filtered = pool.filter((r) => !r.cuisines.some((c) => excluded.includes(c)));
  return drawRandom(filtered.length ? filtered : pool);
}
